using System;
using System.Windows;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;

using Action_Items.Views;
using Action_Items.Services;

namespace Action_Items
{
    
    public class ModuleInit : IModule
    {
        private readonly IUnityContainer _container;
        private readonly IRegionManager _regionManager;

        public ModuleInit(IUnityContainer container, IRegionManager regionManager)
        {
            _container = container;
            _regionManager = regionManager;
        }

        #region IModule Members

        public void Initialize()
        {
            // Register the DataService concrete type with the container.
            // The DataService's lifetime is controlled by the container so
            // a single instance is created and shared across the application.
            // Change this to swap in another data service implementation.
            _container.RegisterType<IDataService, DataService>(new ContainerControlledLifetimeManager());

            // Display the View in the Shell. Uses Prism's 'View
            // Discovery' mechanism to automatically display the view
            // in the specified named region.
            _regionManager.RegisterViewWithRegion("TopLeftRegion", () => _container.Resolve<View1>());

            // Register the view types with the container so that it can create them
            // during navigation. Note that the container will attempt to create the
            // view as a named object so the views have to be registered as such.
            _container.RegisterType<Object, View1>("View1");

            _regionManager.RegisterViewWithRegion("contentRegion", typeof(Views.ActionItemsView));
        }

        #endregion
    }
}
